<?php  
session_start();
require_once($_SERVER['DOCUMENT_ROOT'].'/mpd/config/config.php');

$nip = $_SESSION['NIP'];
if($_POST["button"] == "Save") {
	
	$nama = $_POST['nama'];
	$gender = $_POST['gender'];
	$dob = $_POST['dob'];
	$pob = $_POST['pob'];
	$height = $_POST['height'];
	$weight = $_POST['weight'];
	$agama = $_POST['agama'];
	$alamat = $_POST['alamat'];
	$kota = $_POST['kota'];
	$telepon = $_POST['telepon'];
	$handphone = $_POST['handphone'];
	$tanggal_masuk = $_POST['tanggal_masuk'];
	$tanggal_tetap = $_POST['tanggal_tetap'];
	$password = $_POST['newpassword'];
	
	$lokasi_file = $_FILES['nama_file']['tmp_name'];
	$nama_file = $_FILES['nama_file']['name'];
	$tipe_file = $_FILES['nama_file']['type'];
	$ukuran_file = $_FILES['nama_file']['size'];
	
	
	$nama_baru = preg_replace("/\s+/", "_", $nip."_profile.jpg");
	$direktori = "../../../img/profile/$nama_baru";
	$MAX_FILE_SIZE = 10000000; //10MB
	move_uploaded_file($lokasi_file, $direktori);
	
	$query=("UPDATE biodata SET NAMA = '$nama', GENDER = '$gender', DOB = '$dob', POB = '$pob', HEIGHT = '$height', WEIGHT = '$weight',
        	AGAMA = '$agama', ALAMAT = '$alamat', KOTA = '$kota', TELEPON = '$telepon', HANDPHONE = '$handphone',  
			TANGGAL_MASUK = '$tanggal_masuk', TANGGAL_TETAP='$tanggal_tetap', PASSWORD_PEGAWAI = '$password', FOTO = '$direktori' WHERE NIP ='$nip'");
	//$query1="UPDATE biodata SET GENDER = '$gender' WHERE NIP ='$nip'";
	
	$result=mysql_query($query);
	//$result=mysql_query($query1);
	header('Location: /mpd/dh/sdm/view/index.php');

}

?>